package main

import (
	"encoding/json"
	"gitee.com/c_z/finsur_spider/utils"
	"os"
)

type ConfigJSONWrapper struct {
	WatchURI     string `json:"WatchURI"`
	WatchID      string `json:"WatchID"`
	WatchIDValue string `json:"WatchIDValue"`
}

var Config ConfigJSONWrapper

//LoadConfig load configure
func LoadConfig(filePath string) (err error) {
	fp, err := os.Open(filePath)
	if err != nil {
		utils.Logger.Error("Open Config file %s error: %s", filePath, err.Error())
		return
	}
	defer fp.Close()

	decoder := json.NewDecoder(fp)
	if err = decoder.Decode(&Config); err != nil {
		utils.Logger.Error("Decode Config Error:%s", err.Error())
		return
	}

	utils.Logger.Debug("Load Config file %s Success", filePath)
	err = nil
	return
}
